// 11/04/2009 Dennis
// Form class is like a window
// all forms will be based on this one
// basically you just add controls to it
class Form extends Control
{
  color bgcolor;
  ArrayList controls;
  String label; // will be displayed in the navigation bar
  String title;
  
  // 11/04/2009 Dennis
  public Form()
  {
    controls = new ArrayList();
    bgcolor = color(100);
    width = scrW;
    height = scrH - 100;
  }
  
  public void setActive() {}
  
  // 11/04/2009 Dennis
  public void updateMouse(int x, int y, int mouseState)
  {
    for(int i = 0; i < controls.size(); i++)
    {
      Control c = (Control)controls.get(i);
      boolean event = c.getEvent(x - c.getX(), y - c.getY(), mouseState);
      if(event)
        processEvent(c);
    }
  }
  
  public void processEvent(Control c)
  {
  }
  
  // 11/04/2009 Dennis
  public void draw()
  {
    width = scrW;
    height = scrH - 100;
    noStroke();
    fill(bgcolor);
    rect(x, y, width, height);
    for(int i = 0; i < controls.size(); i++)
    {
      Control c = (Control)controls.get(i);
      c.draw();
    }
  }
  
  // 11/04/2009 Dennis
  public void addControl(Control c)
  {
    if(c != null)
    {
      c.parent = this;
      controls.add(c);
    }
  }
}
